package com.wbz.create.single;

/**
 * 双重检查锁定
 * 双重检查锁定是一种既保证线程安全又避免同步方法带来的性能开销的方法。
 */
public class SingletonDCL {
    private volatile static SingletonDCL instance;

    private SingletonDCL() {
    }

    public static SingletonDCL getInstance() {
        if (instance == null) {
            synchronized (SingletonDCL.class) {
                if (instance == null) {
                    instance = new SingletonDCL();
                }
            }
        }
        return instance;
    }
}
